#include <bits/stdc++.h>
using namespace std;

// 一个学生的综合信息
struct info
{
    string name;
    float averageScore;
    float pyScore;
    char officer;
    char westerner;
    int paperNum;
    int totalMoney;
    bool champian;
};

int main(int argc, char const *argv[])
{
    // 输入学生个数
    int n;
    cin >> n;

    // 逐个输入学生的信息
    info *a = new info[n];
    for(int i=0; i<n; i++)
    {
        cin >> a[i].name;
        cin >> a[i].averageScore;
        cin >> a[i].pyScore;
        cin >> a[i].officer;
        cin >> a[i].westerner;
        cin >> a[i].paperNum;
    }

    // 统计各个学生的奖学金
    int totalMoney = 0;
    for(int i=0; i<n; i++)
    {
        // 判定是否获得院士奖学金
        if(a[i].averageScore>80 && a[i].paperNum>=1)
            a[i].totalMoney += 8000;

        // 判定是否获得五四奖学金
        if(a[i].averageScore>85 && a[i].pyScore>80)
            a[i].totalMoney += 4000;

        // 判定是否获得成绩优秀奖
        if(a[i].averageScore > 90)
            a[i].totalMoney += 2000;

        // 判定是否获得西部奖学金
        if(a[i].averageScore>85 &&a[i].westerner=='Y')
            a[i].totalMoney += 1000;

        // 判定是否获得班级贡献奖
        if(a[i].pyScore>80 && a[i].officer=='Y')
            a[i].totalMoney += 850;

        // 统计
        totalMoney += a[i].totalMoney;
    }

    // 寻找最大奖金获得者
    int maxMoney = 0;
    string name;
    for(int i; i<n; i++)
    {
        if(a[i].totalMoney > maxMoney)
        {
            maxMoney = a[i].totalMoney;
            name = a[i].name;
        }
    }

    cout << name << endl;
    cout << maxMoney << endl;
    cout << totalMoney << endl;

    return 0;
}
